package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.Map;

@Mapper
public interface UserMapper {

    /**
     * 根据openid查询用户
     *
     * @param openid vx用户标识
     * @return user
     */
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);


    void insert(User user);

    /**
     * 统计用户人数数据
     * @param map
     * @return
     */
    Integer countByMap(Map<String, Object> map);

    /**
     * 查询今日新增用户数
     * @param beginTime 今天开始时间
     * @return 新增用户数量
     */
    @Select("select count(*) from user where create_time between #{beginTime} and now()")
    Integer getTodayUsers(LocalDateTime beginTime);
}
